from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker

from config.settings import Settings


def get_db(db_type: str = "v1"):
    database_url = Settings().database_url_v1
    if db_type == "v2":
        database_url = Settings().database_url_v2
    engine = create_engine(database_url)
    Session = sessionmaker(bind=engine)
    session = Session()
    return session


# 数据库模型基类
Base = declarative_base()
